import Cookies from 'js-cookie'

// 保存token
const TokenKey = 'vue_admin_template_token'
export function getToken() { return Cookies.get(TokenKey) }
export function setToken(token) { return Cookies.set(TokenKey, token, { expires: 1 }) }

// 保存user_id
const UserIdKey = 'vue_admin_template_user_id'
export function setUserId(user_id) { return Cookies.set(UserIdKey, user_id, { expires: 1 }) }
export function getUserId() { return Cookies.get(UserIdKey) }

// 保存部门id
const departmentIdKey = 'vue_admin_template_department_id'
export function setUserDepartmentId(department_id) { return Cookies.set(departmentIdKey, department_id, { expires: 1 }) }
export function getUserDepartmentId(){ return Cookies.get(departmentIdKey) }

// 保存用户昵称
const nickNameKey = 'vue_admin_templat_nick_name'
export function setUserNickName(nick_name){ return Cookies.set(nickNameKey, nick_name, { expires: 1 }) }
export function getUserNickName(){ return Cookies.get(nickNameKey) }

// 保存用户权限
const authorityKey = 'vue_admin_templat_authority_info'
export function setUserAuthority(authority_info){ return Cookies.set(authorityKey, authority_info, { expires: 1 }) }
export function getUserAuthority(){ return Cookies.get(authorityKey) }

// 保存用户红点信息
const reddotKey = 'vue_admin_templat_red_dot'
export function setRedDot(reddot){ return Cookies.set(reddotKey, reddot, { expires: 1 }) }
export function getRedDot(){ return Cookies.get(reddotKey) }

// 退出登录
export function loginOut(){
	Cookies.remove(TokenKey)
	Cookies.remove(UserIdKey)
	Cookies.remove(departmentIdKey)
	Cookies.remove(nickNameKey)
	Cookies.remove(authorityKey)
	Cookies.remove(reddotKey)
}